package bkt.framework.tool;

import bkt.framework.FrameworkConstants;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Base64;
import android.util.Log;

public class FrameworkMobileUtil {

	public static synchronized String getDeviceDbKey(Context context,String sharedPreferencesName) {
		String dbKey = FrameworkMobileUtil.getDeviceIMEI(context)+FrameworkSecurityUtil.getApplicationRandomKey(context,sharedPreferencesName,FrameworkConstants.DB_ENCODE_KEY_NAME); 
		return Base64.encodeToString(dbKey.getBytes(), FrameworkConstants.ENCODE_DECODE_MODE_BASE64);
	}

	public static synchronized String getDeviceIMEI(Context context) {
		String IMEI = null;
		try {
			IMEI = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
		} catch (Exception e) {
			Log.e(FrameworkConstants.LOGTAG_FRAMEWORK_MOBILE_UTIL,"Device IMEI Error",e);
		}
		return IMEI;
	}
	
	
}
